<?php
/**
 * Created by PhpStorm.
 * User: ADMIN
 * Date: 2021/5/31
 * Time: 17:58
 */

namespace app\adminapi\validate;

class MoneyLog extends Base
{
    protected $rule = [
        'page' => 'integer|min:1',
        'limit' => 'integer|min:1|max:20',
        'mobile' => 'checkMobile',
        'user_id' => 'integer|min:1|userExists',
    ];

    protected $message = [
        'mobile.checkMobile' => '手机号格式不正确',

        'user_id.userExists' => '用户不存在',
    ];

    /**
     * 用户是否存在
     */
    protected function userExists($value, $rule, $data)
    {
        if(!db('user')->where('id', $value)->count()) return false;
        return true;
    }
}